import { defineAsyncComponent } from "vue"
import { RouteRecordRaw } from "vue-router"

const asyncComponets = () => {
    return {
        logView: () => import('@/views/LogView.vue'),
        aboutView: () => import('@/views/AboutView.vue'),
        articleView: () => import('@/views/ArticleView.vue'),
        adminView: () => import('@/views/AdminView.vue'),
        writeView: () => import('@/views/WriteView.vue'),
        messageView: () => import('@/views/MessageView.vue'),
        spaceView: () => import('@/views/SpaceView.vue'),
        settingView: () => import('@/views/settingView.vue')
    }
}

const dynamicRoutes: Array<RouteRecordRaw> = [
    {
        path: '/article',
        name: 'Article',
        component: asyncComponets().articleView,
        meta: { title: '文章', roles: ['visitor', 'user', 'admin'], icon: 'article', imgUrl: '' }
    },
    {
        path: '/write',
        name: 'Write',
        component: asyncComponets().writeView,
        meta: { title: '撰写', roles: ['user', 'admin'], icon: 'write', imgUrl: '' }
    },
    {
        path: '/space',
        name: "Space",
        component: asyncComponets().spaceView,
        meta: { title: '空间', roles: ['user', 'admin'], icon: 'space', imgUrl: '' }
    },
    {
        path: '/about',
        name: 'About',
        component: asyncComponets().aboutView,
        meta: { title: '关于', roles: ['visitor', 'user', 'admin'], icon: 'about', imgUrl: '' }
    },
    {
        path: '/message',
        name: 'Message',
        component: asyncComponets().messageView,
        meta: { title: '留言', roles: ['visitor', 'user', 'admin'], icon: 'message', imgUrl: '' }
    },
    {
        path: '/log',
        name: 'Log',
        component: asyncComponets().logView,
        meta: { title: '历程', roles: ['visitor', 'user', 'admin'], icon: 'log', imgUrl: '' }
    },
    {
        path: '/setting',
        name: 'Setting',
        component: asyncComponets().settingView,
        meta: { title: '设置', roles: ['user', 'admin'], icon: 'setting', imgUrl: '' }
    },
    {
        path: '/admin',
        name: 'Admin',
        component: asyncComponets().adminView,
        meta: { title: '管理', roles: ['admin'], icon: 'admin', imgUrl: '' },
    },
]

export default dynamicRoutes